package com.example.module_devices

import androidx.lifecycle.MutableLiveData
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.DeviceEntity
import com.yuwei.http.entity.DeviceEntityItem
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class DeviceViewModel@Inject constructor(
    val apiService: ApiService
): BaseViewModel(){
    val getDeviceSuccess by lazy {
        MutableLiveData<DeviceEntity>()
    }
    fun getDeviceList(){
        executeNetwork({
            apiService.getDeviceList()
        },getDeviceSuccess::postValue)
    }
    val addDeviceSuccess by lazy {
        MutableLiveData<DeviceEntityItem>()
    }
    fun addDevice(deviceEntityItem: DeviceEntityItem){
        executeNetwork({
            apiService.addDevice(deviceEntityItem)
        },addDeviceSuccess::postValue)
    }
}